package org.example.food.service.impl;

import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.food.mapper.CustomerMapper;
import org.example.food.pojo.Customer;
import org.example.food.pojo.User;
import org.example.food.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletionService;

@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;
    @Override
    public boolean login(String userName, String userPwd) {
        QueryWrapper<Customer> qw=new QueryWrapper<>();
        qw.eq("customer_name",userName);
        Customer customer = customerMapper.selectOne(qw);
        if (customer==null){
            return false;
        }

        String s = DigestUtil.md5Hex(userPwd);
        if (s.equals(customer.getPassword())){
            return true;
        }else {
            return false;
        }
    }
}
